// 中号的按钮
import 'package:flutter/material.dart';
import 'package:flutter_color_plugin/flutter_color_plugin.dart';

class MBtn extends StatelessWidget {
  final Function function;
  final String title;
  final bool hasBg;
  final bool hasBorder;
  final Color bgColor;
  final Color borderColor;
  final Color textColor;
  final double btnWidth;
  final double btnHeight;
  final double borderRadius;
  final TextStyle textStyle;

  const MBtn({
    Key key,
    @required this.function,
    this.title,
    this.hasBg = false,
    this.hasBorder = true,
    this.bgColor,
    @required this.borderColor,
    this.btnWidth = 165,
    this.btnHeight = 44,
    this.borderRadius = 22,
    this.textColor = Colors.white,
    this.textStyle,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: function,
      child: Container(
        width: btnWidth,
        height: btnHeight,
        // padding: EdgeInsets.fromLTRB(0, 10, 0, 10),
        decoration: BoxDecoration(
            color: hasBg ? bgColor : Colors.transparent,
            border: Border.all(color: borderColor, width: 1),
            borderRadius: BorderRadius.circular(borderRadius)),
        child: Center(child: DefaultTextStyle(
          style: TextStyle(
              fontSize: 16,
              color: hasBg ? textColor : borderColor,
              decoration: TextDecoration.none),
          child: Text(
            title,
            textAlign: TextAlign.center,
            style: textStyle,
          ),
        ),),
      ),
    );
  }
}
